package request

import (
	"bytes"
	"github.com/gin-gonic/gin"
	"io/ioutil"
)
import "encoding/json"

func JsonMap(c *gin.Context) map[string]interface{} {
	body, _ := c.GetRawData()
	if len(body) == 0 {
		return nil
	}
	c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(body)) // 重新放回去
	var data map[string]interface{}
	err := json.Unmarshal(body, &data)
	if err != nil {
		return nil
	}
	return data
}
